import requests
import execjs



t = 'app=CailianpressWeb&category=&lastTime=1725438631&last_time=1725438631&os=web&refresh_type=1&rn=20&sv=7.7.5'

with open('caiCode.js',mode='r',encoding='utf-8') as file:
    scriptFile = file.read()

ctx = execjs.compile(scriptFile)
sign = ctx.call('getSign',t)
# print(sign)
url = f'https://www.cls.cn/nodeapi/telegraphList?app=CailianpressWeb&category=&lastTime=1725438631&last_time=1725438631&os=web&refresh_type=1&rn=20&sv=7.7.5&sign={sign}'

headers = {
    'Accept':'application/json, text/plain, */*',
    'Accept-Encoding':'gzip, deflate, br',
    'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'Connection':'keep-alive',
    'Content-Type':'application/json;charset=utf-8',
    'Host':'www.cls.cn',
    'Referer':'https://www.cls.cn/',
    'Sec-Ch-Ua':'"Chromium";v="122", "Not(A:Brand";v="24", "Microsoft Edge";v="122"',
    'Sec-Ch-Ua-Mobile':'?0',
    'Sec-Ch-Ua-Platform':'Windows',
    'Sec-Fetch-Dest':'empty',
    'Sec-Fetch-Mode':'cors',
    'Sec-Fetch-Site':'same-origin',
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0'
}


data = {
    'app': 'CailianpressWeb',
    'category': '',
    'lastTime': '1725438631',
    'last_time': '1725438631',
    'os': 'web',
    'refresh_type': '1',
    'rn': '20',
    'sv': '7.7.5',
    'sign':sign
}

response = requests.get(url,headers= headers,data= data).json()
print(response)